import style from '@/assets/components.module.scss';

import {} from '@/components';
import { HttpResponse } from '@/utils';

export interface ProjectProps {
    children?: string | React.ReactElement | React.ReactElement[];
}

function Project({ children }: ProjectProps) {
    console.log(time().format('{YYYY} HH:mm:ss'), `space render`);

    const history = withRouter();
    const id = localStorage.getItem('id');
    if (id == null) {
        history.push('/login');
    }

    const { data } = useSwr<
        HttpResponse<{
            user: {
                avatar: string;
                name: string;
            };
        }>
    >(`user/${id}`, axios.get);

    return (
        <>
            <div className={style['space']}>
                <div className={style['header']}>
                    <div className={style['avatar']}>
                        <img src={data?.data?.user.avatar} alt='avatar' />
                    </div>
                    <div>{data?.data.user.name}</div>
                </div>
                <div className={style['menu']}>
                    <div>{/* <Link to='question'>问答</Link> */}</div>
                    <div>
                        <Link to='comments'>点评</Link>
                    </div>
                </div>
                <div className=''>
                    <Outlet />
                </div>
            </div>
        </>
    );
}

export default Project;
